package com.mmall.admin.filters;

import com.mmall.admin.shiro.ShiroOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.ServletContextRequestLoggingFilter;

import javax.servlet.http.HttpServletRequest;

/**
 * @author gg
 * @version RequestLogFilter.java, v 0.1 2019-05-24 16:12 gg
 */
@Slf4j
@Component
public class RequestLogFilter extends ServletContextRequestLoggingFilter {

    /**
     * Writes a log message before the request is processed.
     */
    @Override
    protected void beforeRequest(HttpServletRequest request, String message) {
        getServletContext().log(message);
    }

    /**
     * Writes a log message after the request is processed.
     */
    @Override
    protected void afterRequest(HttpServletRequest request, String message) {
        getServletContext().log(message);
        ShiroOperation.remove();
    }
}